<!--************************************************************ -->
<!--* 文件创建日期：2010                                  * -->
<!--* 文件修改日期：			                                   * -->
<!--************************************************************ -->
<!--JSP初始化设置-->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.infomanage.po.*" %>
<%@page import="com.infomanage.vo.*" %>
<%@page import="com.infomanage.util.*"%>
<%@page import="com.infomanage.service.worklog.*"%>
<%  response.addDateHeader("Expires", 0);response.setHeader("Pragma","no-cache"); response.setHeader("Cache-Control","no-cache");%>
<%
	request.setCharacterEncoding("UTF-8");
	String dutyId = request.getParameter("dutyId");
    if(dutyId == null) dutyId = "";
    
    DutylogItem dutyItem = DutylogService.loadDutylog(request, response, out);
    int personId = -1;
    String personname = "";
    String begintime = "";
    String endtime = ""; 
    String importwork = "";
    String notify = "";
    String problem = "";
    String todo = "";
    String beginDay = "";
    String beginHour = "";
    String beginMinute = "";
    String endDay = "";
    String endHour = "";
    String endMinute = "";
    if(dutyItem != null) {
    	Dutylog duty = dutyItem.getBean();
    	Person person = dutyItem.getPerson();
	    personId = duty.getPersonId();
	    personname = person.getName();
	    begintime = duty.getBegintime();
	    endtime = duty.getEndtime();
	    importwork = duty.getImportWork();
	    notify = duty.getNotify();
	    problem = duty.getProblem();
	    todo = duty.getTodo();
	    if(begintime != null){
	    	String[] timeArray = begintime.split(";");
	    	if(timeArray.length == 3){
		    	beginDay = timeArray[0];
		    	beginHour = timeArray[1];
		    	beginMinute = timeArray[2];
	    	}
	    }
	    if(endtime != null){
	    	String[] timeArray = endtime.split(";");
	    	if(timeArray.length == 3){
		    	endDay = timeArray[0];
		    	endHour = timeArray[1];
		    	endMinute = timeArray[2];
	    	}
	    }
    } 
%>
<html>
<head>
	<title>当班日志</title>
	<META HTTP-EQUIV="Pragma" CONTENT="no-cache">	
	<link href="../../css/table.css" rel="stylesheet" type="text/css">
	<link href="../../css/calendar.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="../../js/calendar.js"></script>
	<script type="text/javascript" src="../../js/common.js"></script>
	<script type="text/javascript">
	   function init() {
		   if("" != "<%=dutyId%>") { // 修改
		   	   form1.personId.value = "<%=personId%>";
			   form1.personname.value = "<%=personname%>";
			   form1.begintime.value = "<%=begintime%>";
			   form1.endtime.value = "<%=endtime%>";
			   form1.importwork.value = "<%=importwork%>";
			   form1.notify.value = "<%=notify%>";
			   form1.problem.value = "<%=problem%>";
			   form1.todo.value = "<%=todo%>";
			   form1.beginDay.value = "<%=beginDay%>";
			   form1.beginHour.value = "<%=beginHour%>";
			   form1.beginMinute.value = "<%=beginMinute%>";
			   form1.endDay.value = "<%=endDay%>";
			   form1.endHour.value = "<%=endHour%>";
			   form1.endMinute.value = "<%=endMinute%>";
		   }
	   }
	   // 提交
	   function doSubmit(){
	   		if(validate()){
	   			return;
	   		}
		 	if("" == "<%=dutyId%>") {
		 		form1.actionType.value = "add";
			}else {
		 		form1.actionType.value = "modify";
			}
			form1.begintime.value = form1.beginDay.value + ";" + form1.beginHour.value + ";" + form1.beginMinute.value;
			form1.endtime.value = form1.endDay.value + ";" + form1.endHour.value + ";" + form1.endMinute.value;
		 	form1.submit();
	   }

	   function showError(error){
		   alert(error);
	   }

	   function showInfo(info){
		   alert(info);
		   window.returnValue = "ok";
		   window.close();
	   }
	   
	   function validate(){
	   		if(form1.personname.value == ""){
	   			alert("值班人不能为空！");
	   			return true;
	   		}
	   		if(form1.beginDay.value == ""){
	   			alert("值班开始时间不能为空！");
	   			return true;
	   		}
	   		if(form1.endDay.value == ""){
	   			alert("值班结束时间不能为空！");
	   			return true;
	   		}
	   		
	   		if(form1.importwork.value.length > 4000){
	   			alert("值班重点工作不能超过4000个字！");
	   			return true;
	   		}
	   		
	   		if(form1.notify.value.length > 4000){
	   			alert("上级通知不能超过4000个字！");
	   			return true;
	   		}
	   		
	   		if(form1.todo.value.length > 4000){
	   			alert("待办事宜不能超过4000个字！");
	   			return true;
	   		}
	   		
	   		if(form1.problem.value.length > 4000){
	   			alert("存在问题不能超过4000个字！");
	   			return true;
	   		}
	   		return false;
	   }
	</script>
</head>
<body  rightmargin="0" bottommargin="0" leftmargin="0" topmargin="0" onclick="clickBody();" onload="init();">
	<form name="form1" action="atworklog_action.jsp" method="post" target="actionFrame">
	<input type="hidden" name="dutyId" value="<%=dutyId%>">
	<input type="hidden" name="actionType">
	<input type="hidden" name="begintime">
	<input type="hidden" name="endtime">
	<table class="dialogTable" cellpadding="0" cellspacing="0">
		<!-- 表头-->
		<tr class="dialogTableHeader">
			<td>当班日志</td>
		</tr>
		<!-- 表数据-->
		<tr class="dialogTableContent">
			<td>
				<!-- 数据项 -->
				<table class="dataTable">
					<col width="20%">
					<col width="80%">
					<tr>
						<td class="field">
							值班人
						</td>
						<td>
							<span class="treeSpan" onclick="showTree(this, '../common/personTree.jsp');" treeSelect="true">
								<input name="personname" nodeId="" id="deptTreeInput" value="" 
									style="width: 350px;" readonly="readonly" 
									treeSelect="true"><input name="personId" value="" type="hidden">
							</span>
						</td>
					</tr>
					<tr>
						<td class="field">
							值班开始时间
						</td>
						<td>
   							<input name="beginDay" type="text" style="width: 200px;cursor: hand;" id="time2" onClick="return showCalendar(this.id, 'y-mm-dd');" readonly="readonly"><img 
							src="../../img/tip_calender.gif" style="cursor: hand;" width="16" height="16" onClick="return showCalendar('time2', 'y-mm-dd');">
		   							&nbsp;&nbsp;<select name="beginHour">
			   							<%
			   							String[] startHours = TimeUtil.get24Hours();
			   								for(int i = 0; i < startHours.length; i++){
			   							%>
			   							<option value="<%=startHours[i]%>"><%=startHours[i]%></option>
			   							<%
			   								}
			   							%>
		   							</select>
		   							时
		   							&nbsp;&nbsp;<select name="beginMinute">
			   							<%
			   							String[] beginMinutes = TimeUtil.get60Minutes();
			   								for(int i = 0; i < beginMinutes.length; i++){
			   							%>
			   							<option value="<%=beginMinutes[i]%>"><%=beginMinutes[i]%></option>
			   							<%
			   								}
			   							%>
		   							</select>
		   							分
						</td>
					</tr>
					<tr>
						<td class="field">
							值班结束时间
						</td>
						<td>
							<input name="endDay" type="text" style="width: 200px;cursor: hand;" id="time" onClick="return showCalendar(this.id, 'y-mm-dd');" readonly="readonly"><img 
							src="../../img/tip_calender.gif" style="cursor: hand;" width="16" height="16" onClick="return showCalendar('time', 'y-mm-dd');">
		   							&nbsp;&nbsp;<select name="endHour">
			   							<%
			   							String[] endHours = TimeUtil.get24Hours();
			   								for(int i = 0; i < endHours.length; i++){
			   							%>
			   							<option value="<%=endHours[i]%>"><%=endHours[i]%></option>
			   							<%
			   								}
			   							%>
		   							</select>
		   							时
		   							&nbsp;&nbsp;<select name="endMinute">
			   							<%
			   							String[] endMinutes = TimeUtil.get60Minutes();
			   								for(int i = 0; i < endMinutes.length; i++){
			   							%>
			   							<option value="<%=endMinutes[i]%>"><%=endMinutes[i]%></option>
			   							<%
			   								}
			   							%>
		   							</select>
		   							分
						</td>
					</tr>
				</table>
				<table class="dataTable2">
					<col width="20%">
					<col width="20%">
					<col width="60%">
					<tr>
						<td class="field" rowspan="4">
							值班工作情况
						</td>	
						<td class="field">
							值班重点工作
						</td>	
						<td class="field" height="50px">
							<textarea name="importwork" style="width:100%;height:100%"></textarea>
						</td>				
					</tr>
					<tr>
						<td class="field">
							上级通知
						</td>	
						<td class="field" height="50px">
							<textarea name="notify"　style="width:100%;height:100%"></textarea>
						</td>				
					</tr>
					<tr>
						<td class="field">
							待办事宜
						</td>	
						<td class="field" height="50px">
							<textarea name="todo" style="width:100%;height:100%"></textarea>
						</td>				
					</tr>
					<tr>
						<td class="field">
							存在问题
						</td>	
						<td class="field" height="50px">
							<textarea name="problem" style="width:100%;height:100%"></textarea>
						</td>				
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td colspan="2" class="tableBtn">
				<span onclick="doSubmit();">确定</span>
				<span onclick="window.close();">取消</span>
			</td>
		</tr>
		<tr valign="top">
			<td colspan="2">
				&nbsp;
			</td>
		</tr>
	</table>
	</form>
	<iframe src="#" frameborder="0" id="treeFrame" name="frame" style="display: none;position: absolute;"></iframe>
	<iframe src="#" name="actionFrame" style="display: none;"></iframe>
</body>
</html>